package com.ajx.core.app;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.blankj.utilcode.util.SPUtils;

/**
 * Created by lai on 2017/11/28.
 *
 */

public class Cube {

    public static Configurator init(Application context) {
        return Configurator.getInstance().withContext(context);
    }

    public static Configurator getConfigurator() {
        return Configurator.getInstance();
    }

    public static <T> T getConfiguration(ConfigKeys key) {
        return getConfigurator().getConfiguration(key);
    }

    public static Context getApplication(){
        return getConfiguration(ConfigKeys.CONTEXT);
    }

    public static SPUtils getSp(){
        String spName = getConfiguration(ConfigKeys.SP_NAME);
        if (spName!=null){
            return SPUtils.getInstance();
        }
        return SPUtils.getInstance(spName);
    }


    public static Handler getBackgroundHandler(){
        return getConfiguration(ConfigKeys.BACKGROUND_HANDLER);
    }
}
